<template>
	<view>
		<image src="https://resource.lanbaozixun.com/uploads/images/20240328195548d49f53095.png" mode="widthFix"
			class="image-fuild" id="apply"></image>
		<view class="form-show-area" >
			<view class="form-area">
				<view class="form-item">
					<view class="form-lable">姓名:</view>
					<u-input v-model="name" placeholder="请输入本人姓名" />
				</view>
				<view class="form-item">
					<view class="form-lable">手机号码:</view>
					<u-input v-model="phone" placeholder="请输入手机号码" />
				</view>
				<view class="form-item" @click="showRegion=true">
					<view class="form-lable">区域:</view>
					<u-input v-model="region" placeholder="请输入选择区域" @click="showRegion=true" disabled type="select" />
				</view>
				<u-select v-model="showRegion" mode="mutil-column-auto" @confirm="regionChange"
					:list="regionLists"></u-select>
				<view class="apply-btn" @click="submitDatas">报名合伙人</view>
			</view>
		</view>
		<image src="https://resource.lanbaozixun.com/uploads/images/2024032909422778ae05862.jpg" mode="widthFix"
			class="image-fuild"></image>
		<image src="https://resource.lanbaozixun.com/uploads/images/202403282036027c5cd8504.jpg" mode="widthFix"
			class="image-fuild"></image>
		<image src="https://resource.lanbaozixun.com/uploads/images/202403282037288b4b59532.jpg" mode="widthFix"
			class="image-fuild"></image>
		<image src="https://resource.lanbaozixun.com/uploads/images/202404091156566673c1904.jpg" mode="widthFix"
			class="image-fuild"></image>
		<image src="https://resource.lanbaozixun.com/uploads/images/202403282042259c9db6988.jpg" mode="widthFix"
			class="image-fuild"></image>
		<view class="information-show-area">
			<view class="information-area">
				<image src="https://resource.lanbaozixun.com/uploads/images/2024032820473500bcc8405.png" mode="widthFix"
					class="contact_us"></image>

				<view class="map-area bg-white">
					<image :src="map" mode="aspectFit" class="image-fuild"></image>
				</view>
				<view class="row contact-information-area">
					<view class="flex-1 phone-area white contact-information">
						<view>电话：{{showPhone||''}}</view>
						<view>扫码添加企业微信沟通咨询</view>
					</view>
					<image :src="qrCode" mode="widthFix" class="qr-code"></image>
				</view>
			</view>
		</view>
		<view class="row-between footer-area">
			<a class="apply-btn" href="#apply">报名合伙人</a>
			<view class="recommend-btn" @click="share">推荐合伙人</view>
		</view>
	</view>
</template>

<script>
	import {
		mapGetters,
		mapActions
	} from 'vuex'
	import {getService,registeredPartner} from "@/api/app"
	import area from '@/utils/area'
	export default {
		data() {
			return {
				name: '',
				phone: '',
				region: '',
				provinceId: '',
				cityId: '',
				districtId: '',
				showRegion: false,
				regionLists: area,
				qrCode:'',
				showPhone:'',
				map:''
			};
		},
		onLoad() {
			this.getServiceFun()
		},
		onShareAppMessage() {
			const shareInfo = Cache.get('shareInfo')
			return {
				title: shareInfo.mnp_share_title,
				path: "pages/index/index?invite_code=" + this.inviteCode
			};
		},
		methods: {
			submitDatas(){
				let _this = this;
				this.$u.debounce(()=>{
					if(_this.$u.test.isEmpty(_this.name)){
						return _this.$u.toast('请输入本人姓名');
					}
					if(_this.$u.test.isEmpty(_this.phone)){
						return _this.$u.toast('请输入手机号码');
					}else if(!_this.$u.test.mobile(_this.phone)){
						return _this.$u.toast('请检查手机号码');
					}
					if(_this.$u.test.isEmpty(_this.region)){
						return _this.$u.toast('请输入选择区域');
					}
					
					registeredPartner({
						name:_this.name,
						phone:_this.phone,
						region:_this.region,
						provinceId:_this.provinceId,
						cityId:_this.cityId,
						districtId:_this.districtId,
					}).then(res=>{
						_this.$u.toast(res.msg);
					})
				}, 500)
			},
			regionChange(region) {
				this.region = region[0].label + " " + region[1].label + " " + region[2].label
				this.provinceId = region[0].value;;
				this.cityId = region[1].value;
				this.districtId = region[2].value
			},
			getServiceFun(){
				let _this = this;
				getService().then(res =>{
					let data = res.data;
					_this.qrCode = data.image;
					_this.showPhone = data.phone;
					_this.map = data.map;
				});
			},
			share(){
				this.$u.toast('分享本页即可');
			}
		},
		computed: {
			...mapGetters(["inviteCode"])
		}

	}
</script>

<style lang="scss">
	page {
		background: #66a6fe;
	}

	.image-fuild {
		width: 100%;
		height: 100px;
		display: block;
	}

	.form-show-area {
		background: url('https://resource.lanbaozixun.com/uploads/images/20240328200200e9b019579.jpg') no-repeat;
		background-size: 100% 100%;

		.form-area {
			width: calc(100% - 2px);
			padding: 48rpx 100rpx 100rpx 100rpx;
			margin: 0 1px;
			background: url('https://resource.lanbaozixun.com/uploads/images/20240328201634f046d4923.png') no-repeat;
			background-size: 100% 100%;

			.form-item {
				display: flex;
				padding: 8rpx 32rpx;
				margin-bottom: 24rpx;
				align-items: center;
				border-radius: 10rpx;
				background-color: #f6f6f6;

				.form-lable {
					font-size: 14px;
					width: 60px;
					margin-right: 16rpx;
					text-align-last: justify;
				}
			}

			.apply-btn {
				color: white;
				margin-top: 80rpx;
				font-size: 28rpx;
				font-weight: bold;
				border-radius: 100rpx;
				line-height: 80rpx;
				text-align: center;
				background-image: linear-gradient(73deg, rgb(234, 13, 13) 0%, rgb(255, 89, 23) 100%);
			}
		}
	}

	.information-show-area {
		padding: 0 10% 80rpx;
		background: #edf6ff;
		background: url('https://resource.lanbaozixun.com/uploads/images/20240328205030318da1705.jpg') no-repeat;
		background-size: 100% 100%;

		.information-area {
			margin-bottom: 24rpx;
			border-radius: 20rpx;
			background-color: #edf6ff;

			.contact_us {
				width: 120px;
				display: inline-block;
				margin-top: -2px;
			}

			.map-area {
				margin: 20rpx 30rpx;
				border-radius: 10rpx;
				border: 4rpx solid #fff;
				
				.image-fuild{
					width: 100%;
					height: 200rpx;
				}
			}

			.contact-information-area {
				margin: 10px 16px 0;
				padding-bottom: 30rpx;

				.contact-information {
					display: flex;
					padding: 30rpx 20rpx;
					font-size: 12px;
					margin-right: 16rpx;
					flex-direction: column;
					background-color: #4c72f8;
					border-radius: 0 50rpx 0 50rpx;
				}

				.qr-code {
					width: 200rpx;
				}
			}
		}
	}

	.footer-area {
		padding: 0 5%;
		padding-bottom: 40rpx;

		.apply-btn,
		.recommend-btn {
			width: calc(50% - 15px);
			color: white;
		}

		.apply-btn {
			display: block;
			line-height: 2.55555556;
			text-align: center;
			text-decoration: none;
			border-radius: 100rpx;
			border: 6rpx solid #FFFFFF;
			text-align: center;
			background-image: linear-gradient(73deg, rgb(234, 13, 13) 0%, rgb(255, 89, 23) 100%);
		}

		.recommend-btn {
			border-radius: 100rpx;
			border: 6rpx solid #FFFFFF;
			text-align: center;
			line-height: 2.55555556;
			background-image: linear-gradient(73deg, rgb(60, 102, 250) 0%, rgb(96, 129, 246) 100%);
		}
	}
</style>